//
//  PersonalDataViewController.m
//  LocomotiveGuards
//
//  Created by zwj on 15-11-30.
//  Copyright (c) 2015年 REDOOR. All rights reserved.
//

#import "PersonalDataViewController.h"
#import "PopLoadMsg.h"
#import "PopMsg.h"
#import "UITextView+Placeholder.h"
#import "SearchAreas.h"
#import "LoginViewController.h"
#import "AlertView.h"

@interface PersonalDataViewController () <UIPickerViewDataSource,UIPickerViewDelegate>
{
    SearchAreas *_searchArea;
    NSArray *_provinceArray;//存放所有省名字
    NSArray *_cityArray;//存放市名字
    NSArray *_districtArray;//存放区名字
    UIButton *_rightBtn;//编辑/完成按钮
    NSArray *_firstArray;//存放个人固定信息标签
    NSArray *_secondArray;//存放个人固定信息内容
    UIView *_addressView;//个人地址背景视图
    UIButton *_provinceBtn;//选择省的按钮
    UIButton *_cityBtn;//选择市的按钮
    UIButton *_districtBtn;//选择区的按钮
    UILabel *_detailLabel; //显示详细信息label
    UIImageView *_detailImgView; //详细信息的背景View
    UITextView *_textView;//编辑详细信息输入框
    UIView *_maskView;//弹出alertView时除alertView以外的视图遮盖层
    UIPickerView *_proPicker;//提示框中的省选择器
    UIPickerView *_cityPicker;//提示框中的市选择器
    UIPickerView *_distPicker;//提示框中的区选择器
    NSDictionary *_listDic;//存放获取的用户信息
    UIView *_alertView;//选择省市区弹出的提示框
}

@property (nonatomic, strong) NSString *userOrTourist;

@end

@implementation PersonalDataViewController
- (instancetype)init {
    self = [super init];
    if (self) {
        _firstArray = @[@"姓名",@"电话",@"身份证号"];
        _secondArray = [NSArray array];
        _listDic = [NSDictionary new];
        _searchArea = [[SearchAreas alloc] init];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.userOrTourist = [[NSUserDefaults standardUserDefaults] objectForKey:@"userOrTourist"];

    [self createMyNav];
    [self configView];
    if ([self.userOrTourist isEqualToString:@"1"]) {
        [self getUserInfoRequest];
    }
}

- (void)createMyNav
{
    [self addTitle:@"个人资料" imageName:@"personaldata"];
    [self addBackBtnTarget:self action:@selector(backBtnClick)];
    _rightBtn = [self addRightBtnTarget:self action:@selector(edit:)];
}

- (void)configView
{
    //创建固定信息（姓名，电话，身份证号）label
    [self createMessageLabel];
    //修改固定信息提示label
    UILabel *tipLabel = [self createLabelFrame:CGRectMake(30*W, 20+44*H+50*H*3, SCREEN_WIDTH-60*W, 50*H) title:@"如要修改以上信息，请联系007客服\n客服电话025-83114007" font:[UIFont systemFontOfSize:13]];
    tipLabel.textColor = [UIColor grayColor];
    tipLabel.textAlignment = NSTextAlignmentLeft;
    tipLabel.numberOfLines = 2;
    [self.view addSubview:tipLabel];
    
    //地址背景View
    _addressView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(tipLabel.frame), SCREEN_WIDTH, 150*H)];
    _addressView.backgroundColor = [UIColor colorWithRed:247.f/255.f green:248.f/255.f blue:248.f/255.f alpha:1.0f];

    //居住地址label
    UILabel *addlabel = [self createLabelFrame:CGRectMake(30*W, 10*H, 100*W, 20*H) title:@"居住地址" font:[UIFont systemFontOfSize:15]];
    addlabel.textAlignment = NSTextAlignmentLeft;
    addlabel.textColor = [UIColor grayColor];
    [_addressView addSubview:addlabel];
    
    //居住地址提示label
    UILabel *addTipLabel = [self createLabelFrame:CGRectMake(130*W, 10*H, SCREEN_WIDTH-150*W, 20*H) title:@"如有变更请及时更新" font:[UIFont systemFontOfSize:13]];
    addTipLabel.textAlignment = NSTextAlignmentLeft;
    addTipLabel.textColor = [UIColor grayColor];
    [_addressView addSubview:addTipLabel];
    
    /**省市区按钮**/
//    _provinceBtn = [self createBtnFrame:CGRectMake(30*W, 40*H, 70*W, 30*H) title:nil bgImageName:@"address" selectedImageName:@"address" target:self action:@selector(selectProvince:)];
    
    _provinceBtn = [[UIButton alloc] initWithFrame:CGRectMake(30*W, 40*H, 70*W, 30*H)];
    _provinceBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [_provinceBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [_provinceBtn setTitle:nil forState:UIControlStateDisabled];
    _provinceBtn.enabled = NO;
    [_addressView addSubview:_provinceBtn];
    
//    _cityBtn = [self createBtnFrame:CGRectMake(105*W, 40*H, 70*W, 30*H) title:nil bgImageName:@"address" selectedImageName:@"address" target:self action:@selector(selectCity:)];
    _cityBtn = [[UIButton alloc] initWithFrame:CGRectMake(105*W, 40*H, 70*W, 30*H)];
    _cityBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [_cityBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [_cityBtn setTitle:nil forState:UIControlStateDisabled];
    _cityBtn.enabled = NO;
    [_addressView addSubview:_cityBtn];
    
    _districtBtn = [self createBtnFrame:CGRectMake(180*W, 40*H, 70*W, 30*H) title:nil bgImageName:@"address" selectedImageName:@"address" target:self action:@selector(selectDistrict:)];
    _districtBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [_districtBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [_districtBtn setTitle:nil forState:UIControlStateDisabled];
    _districtBtn.enabled = NO;
    [_addressView addSubview:_districtBtn];
    
    //显示详细地址信息label
    _detailLabel = [self createLabelFrame:CGRectMake(30*W, 75*H, SCREEN_WIDTH-60*W, 40*H) title:@"" font:[UIFont systemFontOfSize:14]];
    _detailLabel.numberOfLines = 0;
    _detailLabel.textAlignment = NSTextAlignmentLeft;
    _detailLabel.textColor = [UIColor grayColor];
    [_addressView addSubview:_detailLabel];
    
    [self.view addSubview:_addressView];
}

//循环创建固定信息label
- (void)createMessageLabel
{
    for (int i=0; i<3; i++) {
        UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 20+44*H+50*H*i, SCREEN_WIDTH, 50*H-1)];
        bgView.backgroundColor = [UIColor colorWithRed:247.f/255.f green:248.f/255.f blue:248.f/255.f alpha:1.0f];
        
        UILabel *firstLabel = [self createLabelFrame:CGRectMake(30*W, 15*H, 100*W, 20*H) title:_firstArray[i] font:[UIFont systemFontOfSize:15]];
        firstLabel.textAlignment = NSTextAlignmentLeft;
        firstLabel.textColor = [UIColor grayColor];
        [bgView addSubview:firstLabel];
        
        UILabel *secondLabel = [self createLabelFrame:CGRectMake(130*W, 15*H, SCREEN_WIDTH-150*W, 20*H) title:nil font:[UIFont systemFontOfSize:15]];
        secondLabel.textAlignment = NSTextAlignmentLeft;
        secondLabel.textColor = [UIColor grayColor];
        secondLabel.tag = 200+i;
        [bgView addSubview:secondLabel];
        [self.view addSubview:bgView];
        
        UIView *separateView = [self createLabelFrame:CGRectMake(0, 20+44*H+50*H*(i+1)-1, SCREEN_WIDTH, 1) title:nil font:nil];
        separateView.backgroundColor = [UIColor colorWithRed:230.f/255.f green:230.f/255.f blue:230.f/255.f alpha:1.0f];
        [self.view addSubview:separateView];
    }
}

//数据下载完成，重新刷新界面显示
- (void)reloadView
{
    if (!_listDic) {
        return;
    }
    _secondArray = @[[_listDic objectForKey:@"cusName"],[_listDic objectForKey:@"cusMobile"],[_listDic objectForKey:@"idCard"]];
    for (int i=0; i<3; i++) {
        UILabel *label = (UILabel *)[self.view viewWithTag:200+i];
        label.text = _secondArray[i];
    }
    
    [_provinceBtn setTitle:[_listDic objectForKey:@"province"]forState:UIControlStateDisabled];
    [_cityBtn setTitle:[_listDic objectForKey:@"city"]forState:UIControlStateDisabled];
    [_districtBtn setTitle:[_listDic objectForKey:@"district"]forState:UIControlStateDisabled];
    
    _detailLabel.text = [_listDic objectForKey:@"detailAdress"];
}

- (UIPickerView *)showAlertWithIndex:(NSInteger)index
{
    _maskView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    _maskView.backgroundColor = [UIColor colorWithRed:100.f/255.f green:100.f/255.f blue:100.f/255.f alpha:0.5f];
    
    _alertView = [[UIView alloc] initWithFrame:CGRectMake(50*W, 170*H, SCREEN_WIDTH-100*W, 300*H)];
    _alertView.backgroundColor = [UIColor whiteColor];
    _alertView.layer.cornerRadius = 10;
    
    UILabel *alertLabel = [self createLabelFrame:CGRectMake((CGRectGetWidth(_alertView.frame)-100*W)/2, 10*H, 100*W, 30*H) title:@"选择地区" font:[UIFont systemFontOfSize:18]];
    alertLabel.textColor = [UIColor grayColor];
    [_alertView addSubview:alertLabel];
    
    UIButton *cancelBtn = [self createBtnFrame:CGRectMake(0, CGRectGetHeight(_alertView.frame)-35*H+1, (CGRectGetWidth(_alertView.frame)-1)/2, 35*H-1) title:@"取消" bgImageName:nil selectedImageName:nil target:self action:@selector(cancelBtnClicked:)];
    cancelBtn.titleLabel.font = [UIFont systemFontOfSize:18];
    [cancelBtn setTitleColor:[UIColor colorWithRed:(CGFloat)45/255 green:(CGFloat)143/255 blue:(CGFloat)247/255 alpha:1.0] forState:UIControlStateNormal];
    [_alertView addSubview:cancelBtn];
    
    UILabel *horiLabel = [self createLabelFrame:CGRectMake(0, CGRectGetHeight(_alertView.frame)-35*H, CGRectGetWidth(_alertView.frame), 1) title:nil font:nil];
    horiLabel.backgroundColor = [UIColor grayColor];
    [_alertView addSubview:horiLabel];
    
    UILabel *verLabel = [self createLabelFrame:CGRectMake((CGRectGetWidth(_alertView.frame)-1)/2, CGRectGetHeight(_alertView.frame)-35*H, 1, 35*H) title:nil font:nil];
    verLabel.backgroundColor = [UIColor grayColor];
    [_alertView addSubview:verLabel];
    
    UIButton *confirmBtn = [self createBtnFrame:CGRectMake((CGRectGetWidth(_alertView.frame)+1)/2, CGRectGetHeight(_alertView.frame)-35*H+1, (CGRectGetWidth(_alertView.frame)-1)/2, 35*H-1) title:@"确定" bgImageName:nil selectedImageName:nil target:self action:@selector(confirmBtnClicked:)];
    confirmBtn.tag = index;
    confirmBtn.titleLabel.font = [UIFont systemFontOfSize:18];
    [confirmBtn setTitleColor:[UIColor colorWithRed:(CGFloat)45/255 green:(CGFloat)143/255 blue:(CGFloat)247/255 alpha:1.0] forState:UIControlStateNormal];
    [_alertView addSubview:confirmBtn];
    
    UIPickerView *pickerView = [UIPickerView new];
    CALayer *viewLayer = pickerView.layer;
    [viewLayer setFrame:CGRectMake(30*W, 40*H, CGRectGetWidth(_alertView.frame)-60*W, CGRectGetHeight(_alertView.frame)-90*H)];
    [_alertView addSubview:pickerView];
    [_maskView addSubview:_alertView];
    [self.view addSubview:_maskView];
    return pickerView;
}

#pragma mark - 网络请求
//查询用户信息
- (void)getUserInfoRequest
{
    PopLoadMsg *loadmsg = [PopLoadMsg new];
    [loadmsg delayLoadImages];
    
    NSDictionary *paramdic = @{@"loginId":[[NSUserDefaults standardUserDefaults] objectForKey:@"phonenumber"]};
    NSString *url = [urlstring stringByAppendingString:@"getUserInfo.do"];
    
    [K_AppDelegate GenerateHTTPRequestWithUrl:url withParam:paramdic success:^(AFHTTPRequestOperation *op,id responseObject){
        [loadmsg delayImagesRemove];
        NSDictionary *dic = (NSDictionary *)responseObject;
        NSLog(@"dic = %@", dic);
        NSInteger flag = [[dic objectForKey:@"flag"] integerValue];
        if (flag == 0) {
            _listDic = dic;
            [self reloadView];
        }
        
    }failure:^(AFHTTPRequestOperation *op,NSError *error){
        [loadmsg delayImagesRemove];
        [PopMsg showMessage:@"网络异常，请重试" Lasttime:1.0f];
    }];
}

//更新用户信息
- (void)setUserInfoRequest
{
    PopLoadMsg *loadmsg = [PopLoadMsg new];
    [loadmsg delayLoadImages];
    
    NSDictionary *paramdic = @{@"loginId":[[NSUserDefaults standardUserDefaults] objectForKey:@"phonenumber"],
                             @"province":_provinceBtn.currentTitle,
                             @"city":_cityBtn.currentTitle,
                             @"district":_districtBtn.currentTitle,
                             @"detailAdress":_detailLabel.text};
    NSString *url = [urlstring stringByAppendingString:@"setUserInfo.do"];
    
    [K_AppDelegate GenerateHTTPRequestWithUrl:url withParam:paramdic success:^(AFHTTPRequestOperation *op,id responseObject){
        [loadmsg delayImagesRemove];
        NSDictionary *dic = (NSDictionary *)responseObject;
        NSLog(@"dic = %@", dic);
        NSInteger flag = [[dic objectForKey:@"flag"] integerValue];
        NSString *msg = [dic objectForKey:@"msg"];
        if (msg) {
            [PopMsg showMessage:msg Lasttime:1.0f];
        }
        if (flag == 0) {
            NSLog(@"update Success");
            [self getUserInfoRequest];
        }
        
    }failure:^(AFHTTPRequestOperation *op,NSError *error){
        [loadmsg delayImagesRemove];
        [PopMsg showMessage:@"网络异常，请重试" Lasttime:1.0f];
    }];
}

#pragma mark - 点击事件
- (void)backBtnClick
{
    //编辑状态点击返回按钮返回非编辑状态
    if ([[_rightBtn currentTitle] isEqualToString:@"完成"]) {
        _detailLabel.hidden = NO;
        [_textView removeFromSuperview];
        _textView = nil;
        [_detailImgView removeFromSuperview];
        _detailImgView = nil;
        _provinceBtn.enabled = NO;
        _cityBtn.enabled = NO;
        _districtBtn.enabled = NO;
        [_provinceBtn setTitle:[_listDic objectForKey:@"province"]forState:UIControlStateDisabled];
        [_cityBtn setTitle:[_listDic objectForKey:@"city"]forState:UIControlStateDisabled];
        [_districtBtn setTitle:[_listDic objectForKey:@"district"]forState:UIControlStateDisabled];
        _detailLabel.text = [_listDic objectForKey:@"detailAdress"];
        [_rightBtn setTitle:@"编辑" forState:UIControlStateNormal];
    }
    else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)edit:(id)sender
{
    if ([self.userOrTourist isEqualToString:@"1"]) {
        //进入编辑状态
        if ([[_rightBtn currentTitle] isEqualToString:@"编辑"]) {
            _detailLabel.hidden = YES;
            _detailImgView = [[UIImageView alloc] initWithFrame:CGRectMake(30*W, 80*H, SCREEN_WIDTH-60*W, 60*H)];
            [_detailImgView setImage:[UIImage imageNamed:@"detailed_address"]];
            _detailImgView.userInteractionEnabled = YES;
            
            _textView = [[UITextView alloc] initWithFrame:CGRectMake(5*W, 5*H, CGRectGetWidth(_detailImgView.frame)-10*W, CGRectGetHeight(_detailImgView.frame)-10*H)];
            _textView.font = [UIFont systemFontOfSize:13];
            _textView.placeholder = @"补充详细信息";
            _textView.text = _detailLabel.text;
            [_detailImgView addSubview:_textView];
            [_addressView addSubview:_detailImgView];
            
            //重新设置btn的title的State，适配ios8以下版本
            [_provinceBtn setTitle:[_listDic objectForKey:@"province"]forState:UIControlStateNormal];
            //_provinceBtn.enabled = YES;
            [_cityBtn setTitle:[_listDic objectForKey:@"city"]forState:UIControlStateNormal];
            //_cityBtn.enabled = YES;
            [_districtBtn setTitle:[_listDic objectForKey:@"district"]forState:UIControlStateNormal];
            _districtBtn.enabled = YES;
            
            [_rightBtn setTitle:@"完成" forState:UIControlStateNormal];
        }
        //结束编辑状态(点击完成按钮)
        else {
            NSString *message = @"";
            NSString *str1 = [_textView.text stringByReplacingOccurrencesOfString:@" " withString:@""];
            NSString *str2 = [str1 stringByReplacingOccurrencesOfString:@"\n" withString:@""];
            if (str2.length != 0 && _districtBtn.currentTitle.length != 0) {
                _detailLabel.text = _textView.text;
                _detailLabel.hidden = NO;
                [_textView removeFromSuperview];
                _textView = nil;
                [_detailImgView removeFromSuperview];
                _detailImgView = nil;
                
                //_provinceBtn.enabled = NO;
                //_cityBtn.enabled = NO;
                _districtBtn.enabled = NO;
                [self setUserInfoRequest];
                [_rightBtn setTitle:@"编辑" forState:UIControlStateNormal];
            }
            else {
                if (str2.length == 0) {
                    message = @"详细信息不能为空";
                }
                if (_districtBtn.currentTitle.length == 0) {
                    message = @"地区不能为空";
                }
                [PopMsg showMessage:message Lasttime:1.0f];
            }
        }
    }
    else {
        AlertView *alertView = [[AlertView alloc] initWithConfirmButtonBlock:^{
            NSLog(@"登录");
            LoginViewController *loginVC = [[LoginViewController alloc]init];
            [self presentViewController:loginVC animated:YES completion:nil];
        } cancelButtonBlock:^{
            NSLog(@"取消");
        }];
        [self.view addSubview:alertView];
    }
}

//选择省
- (void)selectProvince:(id)sender
{

    _provinceArray = [_searchArea returnProvinces];
    _proPicker = [self showAlertWithIndex:100];
    _proPicker.delegate = self;
    _proPicker.dataSource = self;
    for (NSInteger i=0; i<_provinceArray.count; i++) {
        if ([_provinceArray[i] isEqualToString:_provinceBtn.currentTitle]) {
            [_proPicker selectRow:i inComponent:0 animated:NO];
            break;
        }
        else {
            [_proPicker selectRow:_provinceArray.count/2 inComponent:0 animated:NO];
        }
    }
}

//选择市
- (void)selectCity:(id)sender
{
    if (_provinceBtn.currentTitle.length > 0) {
        _cityArray = [_searchArea returnCitysWithProvince:_provinceBtn.currentTitle];
        _cityPicker = [self showAlertWithIndex:101];
        _cityPicker.delegate = self;
        _cityPicker.dataSource = self;
        for (NSInteger i=0; i<_cityArray.count; i++) {
            if ([_cityArray[i] isEqualToString:_cityBtn.currentTitle]) {
                [_cityPicker selectRow:i inComponent:0 animated:NO];
                break;
            }
            else {
                [_cityPicker selectRow:_cityArray.count/2 inComponent:0 animated:NO];
            }
        }
    }
    else {
        return;
    }
}

//选择区
- (void)selectDistrict:(id)sender
{
    if (_provinceBtn.currentTitle.length > 0 && _cityBtn.currentTitle.length > 0) {
    _districtArray = [_searchArea returnDistrictsWithProvince:_provinceBtn.currentTitle City:_cityBtn.currentTitle];
    _distPicker = [self showAlertWithIndex:102];
    _distPicker.delegate = self;
    _distPicker.dataSource = self;
        for (NSInteger i=0; i<_districtArray.count; i++) {
            if ([_districtArray[i] isEqualToString:_districtBtn.currentTitle]) {
                [_distPicker selectRow:i inComponent:0 animated:NO];
                break;
            }
            else {
                [_distPicker selectRow:_districtArray.count/2 inComponent:0 animated:NO];
            }
        }
    }
    else {
        return;
    }
}

//alertView的取消按钮点击事件
- (void)cancelBtnClicked:(UIButton *)btn
{
    [_alertView removeFromSuperview];
    _alertView = nil;
    [_maskView removeFromSuperview];
    _maskView = nil;
}

//alertView的确定按钮点击事件
- (void)confirmBtnClicked:(UIButton *)btn
{
    if (btn.tag == 100) {
        [_cityBtn setTitle:nil forState:UIControlStateNormal];
        [_districtBtn setTitle:nil forState:UIControlStateNormal];
        NSInteger num = [_proPicker selectedRowInComponent:0];
        NSString *province = _provinceArray[num];
        [_provinceBtn setTitle:province forState:UIControlStateNormal];
    }
    else if (btn.tag == 101) {
        [_districtBtn setTitle:nil forState:UIControlStateNormal];
        NSInteger num = [_cityPicker selectedRowInComponent:0];
        NSString *city = _cityArray[num];
        [_cityBtn setTitle:city forState:UIControlStateNormal];
    }
    else if (btn.tag == 102) {
        NSInteger num = [_distPicker selectedRowInComponent:0];
        NSString *district = _districtArray[num];
        [_districtBtn setTitle:district forState:UIControlStateNormal];
        [_districtBtn setTitle:district forState:UIControlStateDisabled];
    }
    [_alertView removeFromSuperview];
    _alertView = nil;
    [_maskView removeFromSuperview];
    _maskView = nil;
}

//收起键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [_textView resignFirstResponder];
}

#pragma mark- UIPickerView代理函数
//行数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if (pickerView == _proPicker) {
        return _provinceArray.count;
    }
    else if (pickerView == _cityPicker) {
        return _cityArray.count;
    }
    else {
        return _districtArray.count;
    }
}

//一共多少列
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
    return 30;
}

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UILabel *pickerLabel = (UILabel *)view;
    if (pickerView == _proPicker) {
        if (!pickerLabel) {
            pickerLabel = [UILabel new];
            pickerLabel.text = _provinceArray[row];
            pickerLabel.textAlignment = NSTextAlignmentCenter;
            pickerLabel.textColor = [UIColor blackColor];
        }
    }
    
    else if (pickerView == _cityPicker) {
        if (!pickerLabel) {
            pickerLabel = [UILabel new];
            pickerLabel.text = _cityArray[row];
            pickerLabel.textAlignment = NSTextAlignmentCenter;
            pickerLabel.textColor = [UIColor blackColor];
        }
    }

    else if (pickerView == _distPicker) {
        if (!pickerLabel) {
            pickerLabel = [UILabel new];
            pickerLabel.text = _districtArray[row];
            pickerLabel.textAlignment = NSTextAlignmentCenter;
            pickerLabel.textColor = [UIColor blackColor];
        }
    }
    return pickerLabel;
}

#pragma mark -
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
